// 路由表配置，包含所有页面和权限信息
export const routes = [
    {
        path: '/',
        redirect: '/login' // 默认跳转到登录页面
    },
    {
        path: '/login',
        name: 'Login', // 登录页面
        component: () => import('../views/auth/Login.vue'), // 懒加载组件
        meta: { requiresAuth: false } // 不需要认证
    },
    {
        path: '/forgot-password',
        name: 'ForgotPassword', // 忘记密码
        component: () => import('../views/auth/ForgotPassword.vue'), // 懒加载组件
        meta: { requiresAuth: false } // 不需要认证
    },
    {
        path: '/register',
        name: 'Register', // 注册页面
        component: () => import('../views/auth/Register.vue'), // 懒加载组件
        meta: { requiresAuth: false } // 不需要认证
    },
    {
        path: '/dashboard',
        component: () => import('../views/Dashboard.vue'), // 仪表盘作为父页面
        children: [
            {
                path: '',
                name: 'DashboardHome',
                component: () => import('../views/DashboardHome.vue'), // 首页内容
                meta: { requiresAuth: true, permissions: ['dashboard:view'] }
            },
            {
                path: 'user',
                children: [
                    {
                        path: '',
                        name: 'UserList',
                        component: () => import('../views/user/UserList.vue'),
                        meta: { requiresAuth: true, permissions: ['user:view'] }
                    },
                    {
                        path: 'profile/:id',
                        name: 'UserProfile',
                        component: () => import('../views/user/UserProfile.vue'),
                        meta: { requiresAuth: true, permissions: ['user:edit'] }
                    }
                ]
            },
            {
                path: 'role',
                name: 'RoleList',
                component: () => import('../views/role/RoleList.vue'),
                meta: { requiresAuth: true, permissions: ['role:view'] }
            },
            {
                path: 'content',
                children: [
                    {
                        path: '',
                        name: 'ContentList',
                        component: () => import('../views/content/ContentList.vue'),
                        meta: { requiresAuth: true, permissions: ['content:view'] }
                    },
                    {
                        path: 'edit/:id',
                        name: 'ContentEdit',
                        component: () => import('../views/content/ContentEdit.vue'),
                        meta: { requiresAuth: true, permissions: ['content:edit'] }
                    }
                ]
            },
            {
                path: 'data',
                children: [
                    {
                        path: '',
                        name: 'DataList',
                        component: () => import('../views/data/DataList.vue'),
                        meta: { requiresAuth: true, permissions: ['data:view'] }
                    },
                    {
                        path: 'detail/:id',
                        name: 'DataDetail',
                        component: () => import('../views/data/DataDetail.vue'),
                        meta: { requiresAuth: true, permissions: ['data:detail'] }
                    }
                ]
            },
            {
                path: 'system',
                children: [
                    {
                        path: 'settings',
                        name: 'SystemSettings',
                        component: () => import('../views/system/Settings.vue'),
                        meta: { requiresAuth: true, permissions: ['system:settings'] }
                    },
                    {
                        path: 'logs',
                        name: 'Logs',
                        component: () => import('../views/system/Logs.vue'),
                        meta: { requiresAuth: true, permissions: ['system:logs'] }
                    }
                ]
            }
        ]
    },
    {
        path: '/:pathMatch(.*)*', // 匹配所有未定义的路径
        name: 'NotFound',
        component: () => import('../views/NotFound.vue'), // 懒加载组件
        meta: { requiresAuth: false } // 不需要认证
    }
];